[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
system() Execute DOS Command
#include <stdlib.h>
#include <process.h>
int system(string);
const char *string; Command to be executed
system() passes 'string' to the command interpreter COMMAND.COM.
'string' is then executed as if it had been typed at the DOS prompt.
Returns: 0, if successful. -1 if error.
Notes: system() uses the COMSPEC and PATH environment
variables to locate COMMAND.COM.
-------------------------------- Example ---------------------------------
The following statements send a directory listing to the file
"dir.txt":
#include <stdlib.h> /* for 'system' */
#include <stdio.h> /* for 'printf' */
main()
{
int result;
result = system("dir >> dir.txt");
if (result == -1)
printf("error executing system command\n");
}
See Also:
exec...()
spawn...()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson